// 假设 Yn 是 jsrsasign 库的全局变量
const Yn = require('jsrsasign'); 
const Hl = require('crypto-js')
function querySiteAll() {

    const timestamp = Math.floor(Date.now() / 1000);
    // Assuming these variables need to be defined:
    const t = 'GET'; // or whatever HTTP method is needed
    const n = {}; // your data payload
    const i = true; // condition for signature generation
    const r = {"keyword": ""}; // query parameter for signature
    function I$t(e) {
        P$t = '-----BEGIN PRIVATE KEY-----MIICdgIBADANBgkqhkiG9w0BAQEFAASCAmAwggJcAgEAAoGBAJhjSuSPxipWQv3Bp9xBgmdkTNAbdw9K/AVVXkLB1uf4F8Quzds6JI5NXVe3qNJUvU+zyQvIXr+IykWYRpxLGVu16uQrhARVgZWkIM+GJbA4Qo7YWthH9HbvFMSJb9frfUn39fwVOrlZHtXyMjZAsKAX15Ba0GCxE+hdpeaJOZGBAgMBAAECgYAQYZQab84onO9Eof2ucqhW/vQ25szsqu3ekOe6G2ZDt2quny1n5J8rYOuo00hlm9Bh8fyptJdi1YyQ4KauhHAsPgQtdQwglnNsbDWHCbZDT/Ov0m/qFWq0T3C0oMuSRdpv4dC7yRzx4vV2FDJt8op9ALT8cQO+pv23zEx5mDOBJQJBANiGz0aVsh7/4Ga8Q/UvPWyUuPJuG1PT1pGVPafMCh0LICW4zF0e65IJ8VwDhicHzU4V/Y1zMo/CNA9kpK+TL3MCQQC0KyjMmYWcJKbBHoNhrR4oMffVSqcHpghSj1TTdfq9qx1GiLX+Ns2G3CsO4M+IlUD+X6yHhBLi6eUSCIBc71Y7AkA4T7cQUFYmob0mesfhuAttdbAzvFb3Ehy3d+y0+ueWbhJKPSlI/oWdUWCn4XK+K9VE/YsXgmIf6Q3JAw+hadHpAkEAhCTzs70WZkPrmtGKg2W6LLkZkXNDtzRr/kHqcX6i/eI3grha463GaReq7SqujPsLxIbfwDV6tLvgq61YmNFiaQJAX6ptHSmHxiGc9Pt2O6ylhUOsq0gclfSoPvZhOdUZDslXJAeSwgraQRCaPLg1S7hZf/EdQn9qtSpDBVNVuhQAVA==-----END PRIVATE KEY-----'
        let t = P$t;
        return t === null && (t = hve),
        O$t(t, e)
    }
    function O$t(e, t) {
        const n = Yn.KEYUTIL.getKey(e)
        , r = new Yn.KJUR.crypto.Signature({
            alg: "SHA256withRSA"
        });
        return r.init(n),
        r.updateString(t),
        Yn.hextob64(r.sign())
    };
    cUt = {
        BASE_URL: "./",
        DEV: !1,
        MODE: "production",
        PROD: !0,
        SSR: !1,
        VITE_API_BASE_URL: "https://yubin-fuwu.top",
        VITE_API_BASE_WSS: "wss://yubin-fuwu.top",
        VITE_APP_API_KEY: "p_7d695bf4aec4afa458fa2e3e",
        VITE_APP_ENCRYPTION_KEY: "LIUWYSG5NP96Q1BI",
        VITE_APP_HMAC_SECRET: "p_z2tR5sKp9yF3mNvQwXoL4eA7cB1gHj6DfG8uJi0V9o=",
        VITE_APP_IV: "LIUWYSG5NP96Q1BI",
        VITE_APP_PRIVATE_KEY: "-----BEGIN PRIVATE KEY-----MIICdgIBADANBgkqhkiG9w0BAQEFAASCAmAwggJcAgEAAoGBAJhjSuSPxipWQv3Bp9xBgmdkTNAbdw9K/AVVXkLB1uf4F8Quzds6JI5NXVe3qNJUvU+zyQvIXr+IykWYRpxLGVu16uQrhARVgZWkIM+GJbA4Qo7YWthH9HbvFMSJb9frfUn39fwVOrlZHtXyMjZAsKAX15Ba0GCxE+hdpeaJOZGBAgMBAAECgYAQYZQab84onO9Eof2ucqhW/vQ25szsqu3ekOe6G2ZDt2quny1n5J8rYOuo00hlm9Bh8fyptJdi1YyQ4KauhHAsPgQtdQwglnNsbDWHCbZDT/Ov0m/qFWq0T3C0oMuSRdpv4dC7yRzx4vV2FDJt8op9ALT8cQO+pv23zEx5mDOBJQJBANiGz0aVsh7/4Ga8Q/UvPWyUuPJuG1PT1pGVPafMCh0LICW4zF0e65IJ8VwDhicHzU4V/Y1zMo/CNA9kpK+TL3MCQQC0KyjMmYWcJKbBHoNhrR4oMffVSqcHpghSj1TTdfq9qx1GiLX+Ns2G3CsO4M+IlUD+X6yHhBLi6eUSCIBc71Y7AkA4T7cQUFYmob0mesfhuAttdbAzvFb3Ehy3d+y0+ueWbhJKPSlI/oWdUWCn4XK+K9VE/YsXgmIf6Q3JAw+hadHpAkEAhCTzs70WZkPrmtGKg2W6LLkZkXNDtzRr/kHqcX6i/eI3grha463GaReq7SqujPsLxIbfwDV6tLvgq61YmNFiaQJAX6ptHSmHxiGc9Pt2O6ylhUOsq0gclfSoPvZhOdUZDslXJAeSwgraQRCaPLg1S7hZf/EdQn9qtSpDBVNVuhQAVA==-----END PRIVATE KEY-----",
        VITE_BASE_URL: "/api-net"
    }, 
    {VITE_APP_IV: uUt, VITE_APP_ENCRYPTION_KEY: dUt} = cUt, 
    vve = Hl.enc.Utf8.parse(dUt), 
    gve = Hl.enc.Utf8.parse(uUt);
    function hUt(e, t, n) {
        let r = vve
        , i = gve
        , s = Hl.enc.Utf8.parse(e);
        var a = Hl.AES.encrypt(s, r, {
            iv: i,
            mode: Hl.mode.CBC,
            padding: Hl.pad.ZeroPadding
        });
        return Hl.enc.Base64.stringify(a.ciphertext)
    }
    const requestConfig = {
        url: 'https://yubin-fuwu.top/api-net/site/querySiteAll?keyword=',
        method: t,
        data: n,
        headers: {
            "content-type": "application/json",
            timestamp: timestamp,
            signature: "",
            vid: "013d70eed2620514d000cbf8c467628d",
            fid: "013d70eed2620514d000cbf8c467628d",
            apiKey: "",
            userId: "",
            rsaInfo: "",
            Authorization: "Bearer " + "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9"
        }
    };


    requestConfig.headers.vid = "013d70eed2620514d000cbf8c467628d";
    requestConfig.headers.fid = "013d70eed2620514d000cbf8c467628d";
    requestConfig.headers.apiKey = "";
    requestConfig.headers.userId = "";
    
    const signaturePayload = JSON.stringify({
        timestamp: timestamp,
        query: r,
        param: n
    });
    // const signaturePayload = JSON.stringify({"timestamp":1753628135,"query":{"keyword":""},"param":{}})

    
    requestConfig.headers.signature = I$t(signaturePayload);
    requestConfig.headers.rsaInfo = hUt(signaturePayload);
    
    console.log("Signature:", requestConfig.headers.signature);
    console.log("RSAInfo:", requestConfig.headers.rsaInfo);
    var sign_data = {
        "rsainfo": requestConfig.headers.rsaInfo,
        "signature": requestConfig.headers.signature,
        "timestamp": timestamp
    }
    return sign_data;

};

// 调用方式：
querySiteAll("", (error, result) => {
    if (error) {
        console.error("Error:", error);
    } else {
        console.log("Success:", result);
    }
});
